# author: axin
# date: 2021/4/22 18:47
# description:
from rest_framework import serializers

from goods.models import SKU
from orders.models import OrderInfo, OrderGoods


class SKUSerializers(serializers.ModelSerializer):
    """
        SKU商品序列化器
    """
    class Meta:
        model = SKU
        fields = ('name', 'default_image')


class OrderGoosdSerializers(serializers.ModelSerializer):
    """
        订单商品序列化器
    """
    sku = SKUSerializers

    class Meta:
        model = OrderGoods
        fields = ('count', 'price', 'sku')


class OrderSerializers(serializers.ModelSerializer):
    """
        订单序列化器
    """
    skus = OrderGoosdSerializers(many=True)

    class Meta:
        model = OrderInfo
        fields = '__all__'
